﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace Apollo.Configuration
{
    public class SqlTemplate : ConfigurationElement
    {
        [ConfigurationProperty("name", IsRequired = true)]
        public string Name
        {
            get { return (string)this["name"]; }
            set { this["name"] = value; }
        }

        [ConfigurationProperty("value", IsRequired = true)]
        public string Value
        {
            get { return (string)this["value"]; }
            set { this["value"] = value; }
        } 
    }


    public class SqlTemplates : ConfigurationElementCollection {
        public SqlTemplate this[int index] {
            get { return base.BaseGet(index) as SqlTemplate; }
        }

        public override ConfigurationElementCollectionType CollectionType
        {
            get { return ConfigurationElementCollectionType.BasicMap; }
        }

        protected override ConfigurationElement CreateNewElement()
        {
            return new SqlTemplate();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            if(!(element is SqlTemplate))
                return null;

            return ((SqlTemplate)element).Name;
        }

        protected override string ElementName
        {
            get { return "sqlTemplate"; }
        }

    }
}
